using Unity.Entities;
using UnityEngine;

namespace DOTS.DOD.LESSON9
{
    struct SpawnerGenerator : IComponentData
    {
        public Entity SpawnerProtoType;
        public int RadiusX;
        public int RadiusZ;
    }

    public class SpawnerGeneratorAuthoring : MonoBehaviour
    {
        public GameObject SpawnerArchetype;
        public int RadiusX;
        public int RadiusZ;

        class Baker : Baker<SpawnerGeneratorAuthoring>
        {
            public override void Bake(SpawnerGeneratorAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.None);
                AddComponent(entity, new SpawnerGenerator()
                {
                    SpawnerProtoType = GetEntity(authoring.SpawnerArchetype, TransformUsageFlags.Dynamic),
                    RadiusX = authoring.RadiusX,
                    RadiusZ = authoring.RadiusZ,
                });
            }
        }
    }
}